using System.Text;

namespace 进程通讯.客户端
{
    public partial class Form1 : Form
    {
        SocketClient SocketClient = new SocketClient();
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (SocketClient.Connect("127.0.0.1",8001))
            {
                MessageBox.Show("连接成功");
            }
            else
            {
                MessageBox.Show("连接出错");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SocketClient?.Stop();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                SocketClient.Send(Encoding.UTF8.GetBytes(textBox1.Text));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}